<template>
  <div class="login-page">
    <UserForm @onSubmit="onSubmit"></UserForm>
  </div>
</template>

<script>
import UserForm from '@/components/UserForm.vue'
import { login } from '@/api/user'
import { setToken } from '@/utils/storage'
export default {
  name: 'LoginPage',
  components: {
    UserForm
  },
  data () {
    return {}
  },

  methods: {
    async onSubmit (values) {
      const res = await login(values)
      this.$toast.success('登录成功')
      setToken(res.data.token)
      this.$router.push('/')
    }
  }

}
</script>

<style lang="less" scoped>
.link {
  color: #069;
  font-size: 12px;
  padding-right: 20px;
  float: right;
}
</style>
